var firstArr = "sampleString".split('');
var secondArr = "anotherSampleString".split('');

var lengthOfTheShorterOne = firstArr.length;
var isFirstShorter = true;

if (secondArr.length < lengthOfTheShorterOne)
{
    lengthOfTheShorterOne = secondArr.length;
    isFirstShorter = false;
}

var areEqual = true;

for (var i = 0; i < lengthOfTheShorterOne; i++)
{
    if (firstArr[i] < secondArr[i])
    {
        areEqual = false;
        console.log(firstArr + " is higher lexicographically");
        break;
    }
    
    if (firstArr[i] > secondArr[i])
    {
        areEqual = false;
        console.log(secondArr + " is higher lexicographically");
        break;
    }
}

if (areEqual === true)
{
    console.log("Both arrays are equal");
}